package com.gzist.security4.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.ArrayList;

/**
 *  Swagger2配置类
 *  @author: 黄泽建
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {

    // 对于swagger2中是使用Docket来进行配置，而对于swagger3则是使用OpenApi来进行配置
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()   // 配置扫描接口
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))   // 配置扫描方式为基于方法上的注解扫描
                .build()
                .groupName("黄泽建");   //  给接口文档进行分组
    }

    //配置swagger基本信息
    public ApiInfo apiInfo() {
        Contact contact = new Contact("黄泽建","https://blog.csdn.net/m0_74958221?spm=1000.2115.3001.5343","2065501873@qq.com");
        return new ApiInfo(
                "权限管理api文档",
                "树欲静，风不休",
                "1.0",
                "https://blog.csdn.net/m0_74958221?spm=1000.2115.3001.5343", contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
